import { http } from "../http";

const baseUrl = "/api/dms/reservations";

// 添加设备预约记录
export interface AddReservationRequest {
  userCode: string;
  deviceId: string;
  startTime: number;
  endTime: number;
  purpose: string;
  location: string;
  maxAdvanceDays: number;
  usageDurationDays: number;
  frequencyLimit: number;
}
export const addReservationAPI = (params: AddReservationRequest) => {
  return http.post(`${baseUrl}/addReservation`, params);
};

// 归还设备
export interface ReturnDeviceRequest {
  reservationId: string;
  userCode: string;
  returnNote: string;
}
export const returnDeviceAPI = (params: ReturnDeviceRequest) => {
  return http.put(`${baseUrl}/returnDevice`, params);
};

// 获取指定预约记录详细信息（包含审批环节信息）
export const getReservationByIdAPI = (id: string) => {
  return http.get(`${baseUrl}/getReservationById/${id}`);
};

// 更新设备预约使用状态
export interface UpdateUseStatusRequest {
  reservationId: string;
  userCode: string;
  useStatus: string;
}
export const updateUseStatusAPI = (params: UpdateUseStatusRequest) => {
  return http.put(`${baseUrl}/updateUseStatus`, params);
};

interface pageRequest {
  page: number;
  size: number;
  deviceId?: string;
  reservationStatus?: string;
}
export const pageAPI = (params: pageRequest) => {
  return http.post(`${baseUrl}/page`, params);
};
